~ chicken-core (master) /manual/Module (scheme eval)
Trap1[[tags: manual]]2[[toc:]]34== Module (scheme eval)56This module provides R7RS procedures to evaluate expressions dynamically.78=== environment910<procedure>(environment LIST ...)</procedure>1112This procedure returns a specifier for the environment that13results by starting with an empty environment and then14importing each list, considered as an import set, into it.15(See section 5.6 of R7RS for a description of import sets.) The16bindings of the environment represented by the specifier17are immutable, as is the environment itself.1819=== eval2021<procedure>(eval EXPR-OR-DEF [ENVIRONMENT-SPECIFIER])</procedure>2223If EXPR-OR-DEF is an expression, it is evaluated in the specified environment and its values are returned. If it is a definition, the specified identifier(s) are defined in the specified24environment, provided the environment is not immutable.2526The {{ENVIRONMENT-SPECIFIER}} is optional, and if not provided it27defaults to the value of {{(interaction-environment)}}. This is a28CHICKEN extension to R7RS, which, though strictly nonportable, is very29common among Scheme implementations.3031 (eval '(* 7 3) (environment '(scheme base)))32 ==> 213334 (let ((f (eval '(lambda (f x) (f x x))35 (null-environment 5))))36 (f + 10))37 ==> 203839---40Previous: [[Module (scheme file)]]4142Next: [[Module (scheme inexact)]]